package com.cn.web.controller.admin;

import com.alibaba.fastjson2.JSONObject;
import com.cn.bean.pojo.bc.Role;
import com.cn.bean.vo.bc.RoleUserName;
import com.cn.bean.vo.bc.UserJob;
import com.cn.service.server.admin.AdminRoleServer;
import com.cn.service.server.admin.AdminUserServer;
import com.cn.service.server.admin.UserJobServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/Admin")
public class UserJobController {

    private final UserJobServer userJobServer;

    @Autowired
    public UserJobController(UserJobServer userJobServer) {
        this.userJobServer = userJobServer;
    }

    @RequestMapping("/select/ User/Job/")
    @ResponseBody
    public List<UserJob> selectUserJob(@RequestBody JSONObject jsonObject) {
        Integer page = jsonObject.getInteger("page");
        Integer limit = jsonObject.getInteger("limit");
        String jobName = jsonObject.getString("input1");
        String name = jsonObject.getString("input2");
        String username = jsonObject.getString("input3");
        jobName = (jobName != null) ? jobName : "";
        username = (username != null) ? username : "";
        name = (name != null) ? name : "";
        return userJobServer.selectUserJob(limit, page, jobName, name, username);
    }


}
